import axios from './axios'

export const getMealsByElder = (elderId) => axios.get(`/caregiver/meal/byElder/${elderId}`)
export const addMeal = (data) => axios.post('/caregiver/meal/add', data)
export const addMealRecord = (data) => axios.post('/caregiver/meal/add', data)
export const updateMeal = (id, data) => axios.put(`/caregiver/meal/${id}`, data)
export const deleteMeal = (id) => axios.delete(`/caregiver/meal/${id}`)
export const deleteMealRecord = (id) => axios.delete(`/caregiver/meal/${id}`)

// 获取所有老人（管理员用）
export const getElderList = () => axios.get('/elder/page', { params: { current: 1, size: 100 } })

// 获取护工负责的老人
export const getElderListByCaregiver = (caregiverId) =>
    axios.get('/caregiver/elder/list', { params: { caregiverId } })

// 管理员用：查全部餐饮记录
export const getAllMeals = () => axios.get('/caregiver/meal/all')

export const getMealsByCaregiver = (caregiverId) =>
    axios.get(`/caregiver/meal/my-meals`, { params: { caregiverId } })

export const getCaregiverMealRecords = (params) =>
    axios.get(`/caregiver/meal/my-meals`, { params })

export const getEldersByCaregiver = (caregiverId) =>
    axios.get(`/caregiver/elder/my-elders`, { params: { caregiverId } })

export const getMealList = (params) => axios.get('/caregiver/meal/list', { params })

export const updateMealRecord = (data) => axios.put(`/caregiver/meal/${data.mealId}`, data)
// 缺失接口补充
export const mealApi = {
    list: (params) => request.get('/meal', { params }),
    add: (data) => request.post('/meal', data),
    update: (data) => request.put('/meal', data),
    delete: (id) => request.delete(`/meal/${id}`)
}